#pragma once
#include<iostream>
#include<string>
#include<unistd.h>
#include<functional>
#include<vector>
#include<unordered_map>
using namespace std;
typedef  std::function<void()> func;
std::vector<func> callbacks;
std::unordered_map<int,std::string>  desc;
void readMysql()
{
    std::cout<<"sub process["<<getpid()<<"]执行访问数据库的任务"<<std::endl;

}
void excuLeUrl()
{
    std::cout<<"sub process["<<getpid()<<"]执行url解析"<<std::endl;
}

void cal()
{
    std::cout<<"sub process["<<getpid()<<"]执行加密的任务"<<std::endl;
}
void  save()
{
    std::cout<<"sub process["<<getpid()<<"]执行访问数据持久化的任务"<<std::endl;
}

void load()
{
    desc.insert({callbacks.size(),"readMysql:读取数据库"});
    callbacks.push_back(readMysql);
    desc.insert({callbacks.size(),"excuLeUrl：进行url解析"});
    callbacks.push_back(excuLeUrl);
    desc.insert({callbacks.size(),"cal：加密"});
    callbacks.push_back(cal);
    desc.insert({callbacks.size(),"save：保存"});
    callbacks.push_back(save);
}

void showHandler()
{
    for(const auto& iter:desc)
    {
        std::cout<<iter.first<<"\t"<<iter.second<<std::endl;
    }
}

int handlersize()
{
    return callbacks.size();
}